package com.example.user.implicitintent;

/**
 * Created by user on 2018/5/25.
 */
import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.PhoneNumberUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class NewDialer_1Activity extends AppCompatActivity{
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newdialer1);

        final Button button = (Button)findViewById(R.id.Button01);
        final EditText phoneNum=(EditText)findViewById(R.id.phoneNum);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String call=phoneNum.getText().toString();
                if (PhoneNumberUtils.isGlobalPhoneNumber(call)) {
                    //Intent intent=new Intent(<Action>,<Data>);
                    Intent intent=new Intent(Intent.ACTION_CALL,Uri.parse("tel://"+call));
                    startActivity(intent);
                }
               else {
                    Toast.makeText(NewDialer_1Activity.this,R.string.notify_incorrect_phonenum,Toast.LENGTH_LONG).show();
                }
            }
        });
    }
}
